package com.wangyu.springsecuritydemo.entity.primary;

import com.wangyu.springsecuritydemo.entity.BaseEntity;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * @author wangyu
 * @Date 2019/2/19 17:31
 * @Version 1.0
 **/
@Entity
@Table(name = "sys_permission")
public class PermissionEntity extends BaseEntity {

  /**
   * serialVersionUID
   */
  private static final long serialVersionUID = 6646908492537789225L;

  /**
   * 权限名称
   */
  @Column(name = "name", length = 64)
  private String name;

  /**
   * 权限URL
   */
  @Column(name = "resource", length = 64, nullable = false)
  private String resource = "";

  /**
   * 权限描述
   */
  @Column(name = "description")
  private String description;

  /**
   * 权限方法
   */
  @Column(name = "methods", nullable = false)
  private String methods = "";

  /**
   * 对应角色
   */
  @ManyToMany(mappedBy = "permissions")
  private Set<RoleEntity> roles;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getResource() {
    return resource;
  }

  public void setResource(String resource) {
    this.resource = resource;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getMethods() {
    return methods;
  }

  public void setMethods(String methods) {
    this.methods = methods;
  }

  public Set<RoleEntity> getRoles() {
    return roles;
  }

  public void setRoles(Set<RoleEntity> roles) {
    this.roles = roles;
  }
}
